<%@ page language="java" pageEncoding="UTF-8"%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html:html lang="true">
<head>
	<html:base />

	<title>dtree.jsp</title>

	<meta http-equiv="pragma" content="no-cache" />
	<meta http-equiv="cache-control" content="no-cache" />
	<meta http-equiv="expires" content="0" />
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3" />
	<meta http-equiv="description" content="This is my page" />
	<script type="text/javascript" src="../../js/dtree_checkbox.js"></script>
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/dtree.css" />

</head>

<body>
	<div id="dtree_checkbox">
	<script type="text/javascript">
		d = new dTree('d');
		<logic:iterate id="treeNodeForm" name="treeNodeFormList">
			d.add(${treeNodeForm.id},${treeNodeForm.parentId},'<input type="checkbox" name="" id="checkbox${treeNodeForm.parentId},${treeNodeForm.id}" value="" onclick="selectSonNode(this.id, this.checked);" />${treeNodeForm.name}','','','${treeForm.target}');
		</logic:iterate>
		document.write(d);
		
		function selectSonNode(checkboxId, checked){
			var ids = checkboxId.substr(8,checkboxId.length).split(",");
			var parentId = ids[0];
			var id = ids[1];
				var inputs = document.getElementById("dtree_checkbox").getElementsByTagName("input");
				for(var i=0; i<inputs.length; i+=1){
					if(inputs[i].type == "checkbox"){
						var inputIds = inputs[i].id.substr(8,checkboxId.length).split(",");
						if(inputIds[0] == id){
							inputs[i].checked = checked;
							selectSonNode(inputs[i].id, checked);
						}
					}
				}
		}
	</script>
	</div>
</body>
</html:html>
